<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2805018_32h9irf2jd5.css">
    <link rel="shortcut icon" href="https://www.bilibili.com//favicon.ico" type="image/x-iocn">
    <style>
        #b{
            width: 1200px;
        }
    </style>
</head>
<body>
    <input type="text" name="" id="a"><br>
    <button id="btn">所示</button><br>
    <input type="text" name="" id="b">
</body>
<script>
    var aInp = document.getElementById("a");
    var bInp = document.getElementById("b");
    
    btn.onclick = function () {
        var a = aInp.value;
        var c = 1;

        debugger;
        for(var i = 2; i < a ; i++){
            if(a % i == 0){
                var c = 0;
                break;
            }
        }
        c == 0 ? b.value = a + "不是素数" : b.value = a + "是素数";
        /* if(c = false){
            b.value = a + "不是素数";
        }else(c = true){
            b.value = a + "是素数";
        } */
    }
</script>
</html>